//
//  HOMFastTrampoline.h
//  HigherOrderMessaging
//
//  Created by Ofri Wolfus on 21/05/06.
//  Copyright 2006 Ofri Wolfus. All rights reserved.
//

//#import <HigherOrderMessaging/HOMTrampoline.h>
#include <objc/objc-class.h>


#if 0
typedef struct _HOMMessage {
	Method		method;
	marg_list	args;
}	HOMMessage;

typedef struct _HOMMessageList {
	int			count;
	HOMMessage	*message_list;	/* variable length list */
} HOMMessageList;
#endif

@interface HOMFastTrampoline : NSProxy {
	id				target;
	SEL				selector;
	unsigned		lifeTime;
	//HOMMessageList	messages;
}

/*!
 * @method trampolineWithTarget:selector:
 * @result Returns a new initialized (not autoreleased!) trampoline object with life time of 1 invocation.
 * @param aTarget is the target of the trampoline.
 * @param aSelector is the selector that gets sent to the target. This selector must take 2 arguments.
 * The first is the selector of the message.
 * The second is of type <code>marg_list</code> and contains all the arguments passed to with the message.
 */
+ (id)trampolineWithTarget:(id)aTarget selector:(SEL)aSelector;

/*!
 * @method trampolineWithTarget:selector:lifeTime:
 * @result Returns a new initialized (not autoreleased!) trampoline object.
 * @param aTarget The target of the trampoline.
 * @param aSelector The selector that gets sent to the target.
 * @param numberOfMessages The number of messages the trampoline will live.
 * @discussion If the life time of the new trampoline is larger then 1, the selector passed should take one argument, which is a pointer to <code>HOMMessageList</code>.
 * You should not free this message list as the trampoline will do it when it deallocates.
 * If the life time is 1, the selector passed should take one <code>marg_list</code> argument.
 */
+ (id)trampolineWithTarget:(id)aTarget selector:(SEL)aSelector lifeTime:(unsigned)numberOfMessages;

/*!
 * @method initWithTarget:selector:
 * @result An initialized trampoline object with life time of 1 invocation.
 * @param aTarget is the target of the trampoline.
 * @param aSelector is the selector that gets sent to the target. This selector must take 1 argument which is of type <code>marg_list</code>.
 */
- (id)initWithTarget:(id)aTarget selector:(SEL)aSelector;

/*!
 * @method initWithTarget:selector:
 * @result An initialized trampoline object.
 * @param aTarget is the target of the trampoline.
 * @param aSelector is the selector that gets sent to the target.
 * @param numberOfMessages The number of messages the trampoline will live.
 * @discussion If the life time of the new trampoline is larger then 1, the selector passed should take one argument, which is a pointer to <code>HOMMessageList</code>.
 * You should not free this message list as the trampoline will do it when it deallocates.
 * If the life time is 1, the selector passed should take one <code>marg_list</code> argument.
 */
- (id)initWithTarget:(id)aTarget selector:(SEL)aSelector lifeTime:(unsigned)numberOfMessages;

@end

@interface NSObject (HOMFastTrampolineTarget)
- (Method)objcMethodForSelector:(SEL)selector;
@end
